/**
  ******************************************************************************
  * @file    gt32f030_gpio.c
  * @author  GT Application Team
  * @version V1.0.0
  * @date    03-January-2025
  *       
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2022 Giantec Semicondutor Inc</center></h2>
  *
  *             http://www.giantec-semi.com/
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GT32F030_GPIO_H
#define __GT32F030_GPIO_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "gt32f030.h"

/** @addtogroup GT32F030_StdPeriph_Driver
  * @{
  */

/** @addtogroup GPIO
  * @{
  */ 
/* Exported macro ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

/** @defgroup GPIO_Exported_Constants
  * @{
  */ 
#define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \
                                    ((PERIPH) == GPIOB) || \
                                    ((PERIPH) == GPIOF))

/** 
  * @brief  GPIO Direction type enumeration 
  */   
typedef enum
{ 
  GPIO_Dir_IN   = 0x00, /*!< GPIO Input Mode */
  GPIO_Dir_OUT  = 0x01, /*!< GPIO Output Mode */
}GPIODir_TypeDef;
#define IS_GPIO_DIR(DIR) (((DIR) == GPIO_Dir_IN)  || ((DIR) == GPIO_Dir_OUT) )

/** 
  * @brief  GPIO Output type enumeration 
  */  
typedef enum
{ 
  GPIO_OType_PP = 0x00,
  GPIO_OType_OD = 0x01
}GPIOOType_TypeDef;
#define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD))


/** 
  * @brief  GPIO Output Slew rate enumeration 
  */  
typedef enum
{ 
  GPIO_Speed_High   = 0x00, /*!< High speed Slewrate    */
  GPIO_Speed_Low    = 0x01  /*!< Low speed Slewrate   */
}GPIOSpeed_TypeDef; 
#define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_High) || ((SPEED) == GPIO_Speed_Low) ) 


/** 
  * @brief  GPIO Configuration PullUp PullDown enumeration 
  */ 
typedef enum
{ 
  GPIO_PuPd_NOPULL = 0x00,
  GPIO_PuPd_UP     = 0x01,
  GPIO_PuPd_DOWN   = 0x02
}GPIOPuPd_TypeDef;
#define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \
                            ((PUPD) == GPIO_PuPd_DOWN))


typedef enum
{ 
  GPIO_Drv_Strong = 0x00,
  GPIO_Drv_Normal = 0x01
}GPIODrv_TypeDef;
#define IS_GPIO_DRV(DRV) (((DRV) == GPIO_Drv_Strong) || ((DRV) == GPIO_Drv_Normal))


/** 
  * @brief  GPIO Bit SET and Bit RESET enumeration 
  */ 
typedef enum
{ 
  Bit_RESET = 0,
  Bit_SET
}BitAction;
#define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET))


/** 
  * @brief  Interrupt Trigger enumeration  
  */
typedef enum
{
	GPIO_IntTrigger_FallEdge   = 0x00,
  GPIO_IntTrigger_RiseEdge   = 0x01,
  GPIO_IntTrigger_LowLevel   = 0x02,
	GPIO_IntTrigger_HighLevel  = 0x03,	
	GPIO_IntTrigger_BothEdge   = 0x04
}GPIOIntTrigger_TypeDef;
#define IS_GPIO_INTTRIGGER(TRIGGER) (((TRIGGER) == GPIO_IntTrigger_FallEdge)  || \
																		 ((TRIGGER) == GPIO_IntTrigger_RiseEdge)  || \
																		 ((TRIGGER) == GPIO_IntTrigger_BothEdge)  || \
																		 ((TRIGGER) == GPIO_IntTrigger_HighLevel) || \
                                     ((TRIGGER) == GPIO_IntTrigger_LowLevel))



/** 
  * @brief  GPIO Debounce Enable&Synchronization command  
  */
#define GPIO_DBCR1_SYNCEN                     ((uint32_t)0x00010000)
#define GPIO_DBCR1_PIN0EN                     ((uint32_t)0x00000001)
#define GPIO_DBCR1_PIN1EN                     ((uint32_t)0x00000002)
#define GPIO_DBCR1_PIN2EN                     ((uint32_t)0x00000004)
#define GPIO_DBCR1_PIN3EN                     ((uint32_t)0x00000008)
#define GPIO_DBCR1_PIN4EN                     ((uint32_t)0x00000010)
#define GPIO_DBCR1_PIN5EN                     ((uint32_t)0x00000020)
#define GPIO_DBCR1_PIN6EN                     ((uint32_t)0x00000040)
#define GPIO_DBCR1_PIN7EN                     ((uint32_t)0x00000080)
#define GPIO_DBCR1_PIN8EN                     ((uint32_t)0x00000100)
#define GPIO_DBCR1_PIN9EN                     ((uint32_t)0x00000200)
#define GPIO_DBCR1_PIN10EN                    ((uint32_t)0x00000400)
#define GPIO_DBCR1_PIN11EN                    ((uint32_t)0x00000800)
#define GPIO_DBCR1_PIN12EN                    ((uint32_t)0x00001000)
#define GPIO_DBCR1_PIN13EN                    ((uint32_t)0x00002000)
#define GPIO_DBCR1_PIN14EN                    ((uint32_t)0x00004000)
#define GPIO_DBCR1_PIN15EN                    ((uint32_t)0x00008000)
#define GPIO_DBCR1_PINMASK                    ((uint32_t)0x0000FFFF)


/** 
  * @brief  GPIO Debounce Clock selection  
  */
#define GPIO_DBCR2_CLKEN                     ((uint32_t)0x00000010)
#define GPIO_DBCR2_1CYCLE                    ((uint32_t)0x00000000)
#define GPIO_DBCR2_2CYCLE                    ((uint32_t)0x00000001)
#define GPIO_DBCR2_4CYCLE                    ((uint32_t)0x00000002)
#define GPIO_DBCR2_8CYCLE                    ((uint32_t)0x00000003)
#define GPIO_DBCR2_16CYCLE                   ((uint32_t)0x00000004)
#define GPIO_DBCR2_32CYCLE                   ((uint32_t)0x00000005)
#define GPIO_DBCR2_64CYCLE                   ((uint32_t)0x00000006)
#define GPIO_DBCR2_128CYCLE                  ((uint32_t)0x00000007)
#define GPIO_DBCR2_256CYCLE                  ((uint32_t)0x00000008)
#define GPIO_DBCR2_512CYCLE                  ((uint32_t)0x00000009)
#define GPIO_DBCR2_1024CYCLE                 ((uint32_t)0x0000000A)
#define GPIO_DBCR2_2048CYCLE                 ((uint32_t)0x0000000B)
#define GPIO_DBCR2_4096CYCLE                 ((uint32_t)0x0000000C)
#define GPIO_DBCR2_8192CYCLE                 ((uint32_t)0x0000000D)
#define GPIO_DBCR2_16384CYCLE                ((uint32_t)0x0000000E)
#define GPIO_DBCR2_32768CYCLE                ((uint32_t)0x0000000F)
#define GPIO_DBCR2_CYCLEMASK                 ((uint32_t)0x0000000F)
#define IS_GPIO_DBCR2_CYCLE(CYCLE)    (((CYCLE) == GPIO_DBCR2_1CYCLE)    || \
                                       ((CYCLE) == GPIO_DBCR2_2CYCLE)    || \
                                       ((CYCLE) == GPIO_DBCR2_4CYCLE)    || \
                                       ((CYCLE) == GPIO_DBCR2_8CYCLE)    || \
                                       ((CYCLE) == GPIO_DBCR2_16CYCLE)   || \
                                       ((CYCLE) == GPIO_DBCR2_32CYCLE)   || \
                                       ((CYCLE) == GPIO_DBCR2_64CYCLE)   || \
                                       ((CYCLE) == GPIO_DBCR2_128CYCLE)  || \
																			 ((CYCLE) == GPIO_DBCR2_256CYCLE)  || \
                                       ((CYCLE) == GPIO_DBCR2_1024CYCLE) || \
                                       ((CYCLE) == GPIO_DBCR2_2048CYCLE) || \
                                       ((CYCLE) == GPIO_DBCR2_4096CYCLE) || \
                                       ((CYCLE) == GPIO_DBCR2_8192CYCLE) || \
                                       ((CYCLE) == GPIO_DBCR2_16384CYCLE)|| \
                                       ((CYCLE) == GPIO_DBCR2_32768CYCLE) )






/** @defgroup GPIO_pins_define 
  * @{
  */ 
#define GPIO_Pin_0                 ((unsigned int)0x0001)  /* Pin 0 selected */
#define GPIO_Pin_1                 ((unsigned int)0x0002)  /* Pin 1 selected */
#define GPIO_Pin_2                 ((unsigned int)0x0004)  /* Pin 2 selected */
#define GPIO_Pin_3                 ((unsigned int)0x0008)  /* Pin 3 selected */
#define GPIO_Pin_4                 ((unsigned int)0x0010)  /* Pin 4 selected */
#define GPIO_Pin_5                 ((unsigned int)0x0020)  /* Pin 5 selected */
#define GPIO_Pin_6                 ((unsigned int)0x0040)  /* Pin 6 selected */
#define GPIO_Pin_7                 ((unsigned int)0x0080)  /* Pin 7 selected */
#define GPIO_Pin_8                 ((unsigned int)0x0100)  /* Pin 0 selected */
#define GPIO_Pin_9                 ((unsigned int)0x0200)  /* Pin 1 selected */
#define GPIO_Pin_10                ((unsigned int)0x0400)  /* Pin 2 selected */
#define GPIO_Pin_11                ((unsigned int)0x0800)  /* Pin 3 selected */
#define GPIO_Pin_12                ((unsigned int)0x1000)  /* Pin 4 selected */
#define GPIO_Pin_13                ((unsigned int)0x2000)  /* Pin 5 selected */
#define GPIO_Pin_14                ((unsigned int)0x4000)  /* Pin 6 selected */
#define GPIO_Pin_15                ((unsigned int)0x8000)  /* Pin 7 selected */
#define GPIO_Pin_All               ((unsigned int)0xFFFF)   /* All pins selected */

#define GPIO_PIN_MASK              ((unsigned int)0x0000FFFF) /* PIN mask for assert test */
#define IS_GPIO_PIN(PIN)           (((PIN) & GPIO_PIN_MASK ) != (unsigned int)0x0000)
#define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \
                              ((PIN) == GPIO_Pin_1) || \
                              ((PIN) == GPIO_Pin_2) || \
                              ((PIN) == GPIO_Pin_3) || \
                              ((PIN) == GPIO_Pin_4) || \
                              ((PIN) == GPIO_Pin_5) || \
                              ((PIN) == GPIO_Pin_6) || \
															((PIN) == GPIO_Pin_7) || \
                              ((PIN) == GPIO_Pin_8) || \
                              ((PIN) == GPIO_Pin_9) || \
                              ((PIN) == GPIO_Pin_10) || \
															((PIN) == GPIO_Pin_11) || \
                              ((PIN) == GPIO_Pin_12) || \
                              ((PIN) == GPIO_Pin_13) || \
                              ((PIN) == GPIO_Pin_14) || \
                              ((PIN) == GPIO_Pin_15)  
/**
  * @}
  */ 


/** @defgroup GPIO_Pin_sources 
  * @{
  */ 
#define GPIO_PinSource0            ((unsigned int)0)
#define GPIO_PinSource1            ((unsigned int)1)
#define GPIO_PinSource2            ((unsigned int)2)
#define GPIO_PinSource3            ((unsigned int)3)
#define GPIO_PinSource4            ((unsigned int)4)
#define GPIO_PinSource5            ((unsigned int)5)
#define GPIO_PinSource6            ((unsigned int)6)
#define GPIO_PinSource7            ((unsigned int)7)
#define GPIO_PinSource8            ((unsigned int)8)
#define GPIO_PinSource9            ((unsigned int)9)
#define GPIO_PinSource10           ((unsigned int)10)
#define GPIO_PinSource11           ((unsigned int)11)
#define GPIO_PinSource12           ((unsigned int)12)
#define GPIO_PinSource13           ((unsigned int)13)
#define GPIO_PinSource14           ((unsigned int)14)
#define GPIO_PinSource15           ((unsigned int)15)
#define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \
                                       ((PINSOURCE) == GPIO_PinSource1) || \
                                       ((PINSOURCE) == GPIO_PinSource2) || \
                                       ((PINSOURCE) == GPIO_PinSource3) || \
                                       ((PINSOURCE) == GPIO_PinSource4) || \
                                       ((PINSOURCE) == GPIO_PinSource5) || \
                                       ((PINSOURCE) == GPIO_PinSource6) || \
																			 ((PINSOURCE) == GPIO_PinSource7) || \
                                       ((PINSOURCE) == GPIO_PinSource8) || \
                                       ((PINSOURCE) == GPIO_PinSource9) || \
                                       ((PINSOURCE) == GPIO_PinSource10) || \
																			 ((PINSOURCE) == GPIO_PinSource11) || \
                                       ((PINSOURCE) == GPIO_PinSource12) || \
                                       ((PINSOURCE) == GPIO_PinSource13) || \
                                       ((PINSOURCE) == GPIO_PinSource14) || \
                                       ((PINSOURCE) == GPIO_PinSource15)
/**
  * @}
  */ 


/** @defgroup GPIO_Alternat_function_selection_define 
  * @{
  */

#define GPIO_PIN_AF_0   ((uint8_t)0x00) // 普通模式
#define GPIO_PIN_AF_1   ((uint8_t)0x01)
#define GPIO_PIN_AF_2   ((uint8_t)0x02)
#define GPIO_PIN_AF_3   ((uint8_t)0x03)
#define GPIO_PIN_AF_4   ((uint8_t)0x04)
#define GPIO_PIN_AF_5   ((uint8_t)0x05)
#define GPIO_PIN_AF_6   ((uint8_t)0x06)
#define GPIO_PIN_AF_7   ((uint8_t)0x07)
#define GPIO_PIN_AF_8   ((uint8_t)0x08)
#define GPIO_PIN_AF_9   ((uint8_t)0x09)
#define GPIO_PIN_AF_10  ((uint8_t)0x0A)
#define GPIO_PIN_AF_11  ((uint8_t)0x0B)
#define GPIO_PIN_AF_12  ((uint8_t)0x0C)
#define GPIO_PIN_AF_13  ((uint8_t)0x0D)
#define GPIO_PIN_AF_14  ((uint8_t)0x0E)
#define GPIO_PIN_AF_15  ((uint8_t)0x0F) // 模拟模式

/** 
  * @brief   PA0 selection  
  */ 
#define PA0_USART1_TX		((uint8_t)0x01)
#define PA0_USART1_RX		((uint8_t)0x02)
#define PA0_QSPI1_SCK		((uint8_t)0x04)
#define PA0_QSPI2_SCK		((uint8_t)0x05)
#define PA0_QSPI2_DIO3	((uint8_t)0x06)
#define PA0_LPTIM_GATE	((uint8_t)0x07)
#define PA0_TIM3_CH4		((uint8_t)0x08)
#define PA0_TIM2_CH1N		((uint8_t)0x09)
#define PA0_QSPI1_DIO3	((uint8_t)0x0A)
#define PA0_TIM5_CH1N		((uint8_t)0x0B)
#define PA0_TIM10_GATE	((uint8_t)0x0C)
#define PA0_COMP1_OUT		((uint8_t)0x0D)
#define PA0_EVENTOUT		((uint8_t)0x0E)

/** 
  * @brief   PA1 selection  
  */ 
#define PA1_USART1_RX		((uint8_t)0x01)		
#define PA1_USART1_TX		((uint8_t)0x02)			
#define PA1_QSPI1_DIO2		((uint8_t)0x04)		
#define PA1_QSPI2_DIO2		((uint8_t)0x05)				
#define PA1_TIM3_CH3		((uint8_t)0x08)		
#define PA1_TIM2_CH2N		((uint8_t)0x09)			
#define PA1_TIM5_CH2N		((uint8_t)0x0B)		
#define PA1_TIM11_TOGN	((uint8_t)0x0C)		
#define PA1_BEEP				((uint8_t)0x0D)		
#define PA1_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PA2 selection  
  */ 
#define PA2_USART0_TX		((uint8_t)0x01)		
#define PA2_USART0_RX		((uint8_t)0x02)		
#define PA2_I2C_SDA			((uint8_t)0x03)		
#define PA2_QSPI1_DIO3		((uint8_t)0x04)		
#define PA2_QSPI2_DIO3		((uint8_t)0x05)		
#define PA2_QSPI2_NSS		((uint8_t)0x06)			
#define PA2_TIM3_CH2		((uint8_t)0x08)		
#define PA2_TIM2_CH3N		((uint8_t)0x09)			
#define PA2_TIM4_BKIN		((uint8_t)0x0B)		
#define PA2_TIM11_EXT		((uint8_t)0x0C)		
#define PA2_COMP2_OUT		((uint8_t)0x0D)		
#define PA2_EVENTOUT		((uint8_t)0x0E)
	
/** 
  * @brief   PA3 selection  
  */ 
#define PA3_USART0_RX		((uint8_t)0x01)		
#define PA3_USART0_TX		((uint8_t)0x02)		
#define PA3_I2C_SCL			((uint8_t)0x03)		
#define PA3_QSPI1_MISO		((uint8_t)0x04)		
#define PA3_QSPI2_MISO		((uint8_t)0x05)		
#define PA3_QSPI2_DIO2		((uint8_t)0x06)			
#define PA3_TIM3_CH1		((uint8_t)0x08)			
#define PA3_QSPI1_DIO2		((uint8_t)0x0A)		
#define PA3_TIM2_ETR		((uint8_t)0x0B)		
#define PA3_TIM11_GATE	((uint8_t)0x0C)		
#define PA3_LVD_OUT			((uint8_t)0x0D)		
#define PA3_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PA4 selection  
  */ 
#define PA4_USART1_TX		((uint8_t)0x01)		
#define PA4_USART1_RX		((uint8_t)0x02)			
#define PA4_QSPI1_MOSI		((uint8_t)0x04)		
#define PA4_QSPI2_MOSI		((uint8_t)0x05)		
#define PA4_QSPI2_DIO3		((uint8_t)0x06)		
#define PA4_LPTIM_TOGN	((uint8_t)0x07)		
#define PA4_TIM4_CH1		((uint8_t)0x08)		
#define PA4_TIM3_CH3N		((uint8_t)0x09)		
#define PA4_QSPI1_DIO3		((uint8_t)0x0A)		
#define PA4_TIM3_ETR		((uint8_t)0x0B)		
#define PA4_TIM10_TOGN	((uint8_t)0x0C)		
#define PA4_BEEP				((uint8_t)0x0D)		
#define PA4_EVENTOUT		((uint8_t)0x0E)	
#define PA4_ADC_CH11    ((uint8_t)0x0F)

/** 
  * @brief   PA5 selection  
  */ 
#define PA5_USART1_RX		((uint8_t)0x01)		
#define PA5_USART1_TX		((uint8_t)0x02)			
#define PA5_QSPI1_DIO2		((uint8_t)0x04)		
#define PA5_QSPI2_DIO2		((uint8_t)0x05)		
#define PA5_MCO					((uint8_t)0x06)		
#define PA5_LPTIM_EXT		((uint8_t)0x07)		
#define PA5_TIM4_CH2		((uint8_t)0x08)		
#define PA5_TIM3_CH2N		((uint8_t)0x09)			
#define PA5_TIM3_BKIN		((uint8_t)0x0B)		
#define PA5_TIM10_EXT		((uint8_t)0x0C)		
#define PA5_COMP1_OUT		((uint8_t)0x0D)		
#define PA5_EVENTOUT		((uint8_t)0x0E)	
#define PA5_ADC_CH10    ((uint8_t)0x0F)

/** 
  * @brief   PA6 selection  
  */ 		
#define PA6_QSPI1_DIO3		((uint8_t)0x04)		
#define PA6_QSPI2_DIO3		((uint8_t)0x05)			
#define PA6_LPTIM_TOG		((uint8_t)0x07)		
#define PA6_TIM4_CH3		((uint8_t)0x08)		
#define PA6_TIM3_CH1N		((uint8_t)0x09)			
#define PA6_TIM5_BKIN		((uint8_t)0x0B)		
#define PA6_TIM10_TOG		((uint8_t)0x0C)		
#define PA6_COMP1_OUT		((uint8_t)0x0D)		
#define PA6_EVENTOUT		((uint8_t)0x0E)	
#define PA6_ADC_CH9     ((uint8_t)0x0F)

/** 
  * @brief   PA7 selection  
  */ 
#define PA7_USART0_TX		((uint8_t)0x01)		
#define PA7_USART0_RX		((uint8_t)0x02)		
#define PA7_I2C_SDA			((uint8_t)0x03)		
#define PA7_QSPI1_NSS		((uint8_t)0x04)		
#define PA7_QSPI2_NSS		((uint8_t)0x05)			
#define PA7_LPTIM_GATE	((uint8_t)0x07)		
#define PA7_TIM4_CH4		((uint8_t)0x08)				
#define PA7_TIM5_CH1N		((uint8_t)0x0B)		
#define PA7_TIM10_GATE	((uint8_t)0x0C)		
#define PA7_COMP2_OUT		((uint8_t)0x0D)		
#define PA7_EVENTOUT		((uint8_t)0x0E)	
#define PA7_ADC_CH8     ((uint8_t)0x0F)

/** 
  * @brief   PA8 selection  
  */ 
#define PA8_USART1_RX		((uint8_t)0x01)		
#define PA8_USART1_TX		((uint8_t)0x02)		
#define PA8_I2C_SCL			((uint8_t)0x03)		
#define PA8_QSPI1_NSS		((uint8_t)0x04)		
#define PA8_QSPI2_NSS		((uint8_t)0x05)		
#define PA8_MCO					((uint8_t)0x06)			
#define PA8_TIM5_CH3		((uint8_t)0x08)		
#define PA8_TIM4_BKIN		((uint8_t)0x09)			
#define PA8_TIM5_CH1		((uint8_t)0x0B)		
#define PA8_TIM11_GATE	((uint8_t)0x0C)			
#define PA8_EVENTOUT		((uint8_t)0x0E)	
#define PA8_ADC_CH2     ((uint8_t)0x0F)

/** 
  * @brief   PA9 selection  
  */ 
#define PA9_USART1_TX		((uint8_t)0x01)		
#define PA9_USART1_RX		((uint8_t)0x02)		
#define PA9_I2C_SCL			((uint8_t)0x03)		
#define PA9_QSPI1_MISO		((uint8_t)0x04)		
#define PA9_QSPI2_MISO		((uint8_t)0x05)		
#define PA9_I2C_SDA			((uint8_t)0x06)			
#define PA9_TIM3_CH1		((uint8_t)0x08)		
#define PA9_TIM5_CH3N		((uint8_t)0x09)			
#define PA9_TIM5_CH2		((uint8_t)0x0B)		
#define PA9_TIM11_EXT		((uint8_t)0x0C)			
#define PA9_EVENTOUT		((uint8_t)0x0E)
#define PA9_ADC_CH3     ((uint8_t)0x0F)

/** 
  * @brief   PA10 selection  
  */ 
#define PA10_USART0_TX	((uint8_t)0x01)		
#define PA10_USART0_RX	((uint8_t)0x02)		
#define PA10_I2C_SDA		((uint8_t)0x03)		
#define PA10_QSPI1_MOSI	((uint8_t)0x04)		
#define PA10_QSPI2_MOSI	((uint8_t)0x05)		
#define PA10_I2C_SCL		((uint8_t)0x06)			
#define PA10_TIM3_CH2		((uint8_t)0x08)		
#define PA10_TIM5_CH2N	((uint8_t)0x09)			
#define PA10_TIM5_CH3		((uint8_t)0x0B)		
#define PA10_TIM11_TOG	((uint8_t)0x0C)			
#define PA10_EVENTOUT		((uint8_t)0x0E)	
#define PA10_ADC_CH4    ((uint8_t)0x0F)

/** 
  * @brief   PA11 selection  
  */ 
#define PA11_USART1_TX	((uint8_t)0x01)		
#define PA11_USART1_RX	((uint8_t)0x02)		
#define PA11_I2C_SCL		((uint8_t)0x03)		
#define PA11_QSPI1_DIO2	((uint8_t)0x04)		
#define PA11_QSPI2_DIO2	((uint8_t)0x05)		
#define PA11_I2C_SDA		((uint8_t)0x06)			
#define PA11_TIM3_CH3		((uint8_t)0x08)		
#define PA11_TIM5_CH1N	((uint8_t)0x09)			
#define PA11_TIM5_CH4		((uint8_t)0x0B)		
#define PA11_TIM11_EXT	((uint8_t)0x0C)		
#define PA11_COMP1_OUT	((uint8_t)0x0D)		
#define PA11_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PA12 selection  
  */ 
#define PA12_USART1_RX	((uint8_t)0x01)		
#define PA12_USART1_TX	((uint8_t)0x02)		
#define PA12_I2C_SDA		((uint8_t)0x03)		
#define PA12_QSPI1_DIO3	((uint8_t)0x04)		
#define PA12_QSPI2_DIO3	((uint8_t)0x05)		
#define PA12_I2C_SCL		((uint8_t)0x06)			
#define PA12_TIM3_CH4		((uint8_t)0x08)		
#define PA12_TIM4_CH3N	((uint8_t)0x09)			
#define PA12_TIM5_ETR		((uint8_t)0x0B)		
#define PA12_TIM11_TOG	((uint8_t)0x0C)		
#define PA12_COMP2_OUT	((uint8_t)0x0D)		
#define PA12_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PA13 selection  
  */ 
#define PA13_USART0_RX	((uint8_t)0x01)		
#define PA13_USART1_TX	((uint8_t)0x02)			
#define PA13_QSPI1_DIO2	((uint8_t)0x04)		
#define PA13_QSPI2_DIO2	((uint8_t)0x05)		
#define PA13_MCO				((uint8_t)0x06)		
#define PA13_LPTIM_TOGN	((uint8_t)0x07)		
#define PA13_TIM4_CH4		((uint8_t)0x08)		
#define PA13_TIM3_CH1N	((uint8_t)0x09)				
#define PA13_TIM11_TOGN	((uint8_t)0x0C)		
#define PA13_BEEP				((uint8_t)0x0D)		
#define PA13_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PA14 selection  
  */ 
#define PA14_USART0_TX	((uint8_t)0x01)		
#define PA14_USART1_RX	((uint8_t)0x02)			
#define PA14_QSPI1_DIO3	((uint8_t)0x04)		
#define PA14_QSPI2_DIO3	((uint8_t)0x05)		
#define PA14_MCO				((uint8_t)0x06)			
#define PA14_TIM4_CH3		((uint8_t)0x08)		
#define PA14_TIM3_CH2N	((uint8_t)0x09)			
#define PA14_TIM5_ETR		((uint8_t)0x0B)		
#define PA14_TIM11_GATE	((uint8_t)0x0C)		
#define PA14_COMP1_OUT	((uint8_t)0x0D)		
#define PA14_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PA15 selection  
  */ 
#define PA15_USART1_RX	((uint8_t)0x01)		
#define PA15_USART1_TX	((uint8_t)0x02)						
#define PA15_LPTIM_TOGN	((uint8_t)0x07)		
#define PA15_TIM4_CH2		((uint8_t)0x08)		
#define PA15_TIM3_CH3N	((uint8_t)0x09)			
#define PA15_TIM5_ETR		((uint8_t)0x0B)		
#define PA15_TIM10_TOGN	((uint8_t)0x0C)		
#define PA15_BEEP				((uint8_t)0x0D)		
#define PA15_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PB0 selection  
  */ 						
#define PB0_TIM5_CH4		((uint8_t)0x08)		
#define PB0_TIM4_CH1N		((uint8_t)0x09)			
#define PB0_TIM5_CH2N		((uint8_t)0x0B)		
#define PB0_TIM11_TOGN	((uint8_t)0x0C)		
#define PB0_COMP1_OUT		((uint8_t)0x0D)		
#define PB0_EVENTOUT		((uint8_t)0x0E)	
#define PB0_ADC_CH7	    ((uint8_t)0x0F)

/** 
  * @brief   PB1 selection  
  */ 		
#define PB1_QSPI1_NSS		((uint8_t)0x04)		
#define PB1_QSPI2_NSS		((uint8_t)0x05)		
#define PB1_MCO					((uint8_t)0x06)			
#define PB1_TIM5_CH1		((uint8_t)0x08)		
#define PB1_TIM4_CH2N		((uint8_t)0x09)			
#define PB1_TIM5_CH3N		((uint8_t)0x0B)		
#define PB1_TIM11_EXT		((uint8_t)0x0C)		
#define PB1_BEEP				((uint8_t)0x0D)		
#define PB1_EVENTOUT		((uint8_t)0x0E)	
#define PB1_ADC_CH6	    ((uint8_t)0x0F)

/** 
  * @brief   PB2 selection  
  */ 
#define PB2_USART0_RX		((uint8_t)0x01)		
#define PB2_USART0_TX		((uint8_t)0x02)			
#define PB2_QSPI1_SCK		((uint8_t)0x04)		
#define PB2_QSPI2_SCK		((uint8_t)0x05)		
#define PB2_QSPI2_NSS		((uint8_t)0x06)			
#define PB2_TIM5_CH2		((uint8_t)0x08)		
#define PB2_TIM4_CH3N		((uint8_t)0x09)		
#define PB2_QSPI1_NSS		((uint8_t)0x0A)		
#define PB2_TIM2_CH2N		((uint8_t)0x0B)		
#define PB2_TIM11_TOG		((uint8_t)0x0C)			
#define PB2_EVENTOUT		((uint8_t)0x0E)	
#define PB2_ADC_CH5     ((uint8_t)0x0F)

/** 
  * @brief   PB3 selection  
  */ 
#define PB3_LPTIM_TOG		((uint8_t)0x07)		
#define PB3_TIM4_CH1		((uint8_t)0x08)				
#define PB3_TIM5_BKIN		((uint8_t)0x0B)		
#define PB3_TIM10_EXT		((uint8_t)0x0C)			
#define PB3_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PB4 selection  
  */ 
#define PB4_USART0_TX		((uint8_t)0x01)		
#define PB4_USART0_RX		((uint8_t)0x02)					
#define PB4_QSPI2_DIO2		((uint8_t)0x06)		
#define PB4_LPTIM_GATE	((uint8_t)0x07)		
#define PB4_TIM5_CH1		((uint8_t)0x08)		
#define PB4_TIM4_CH3N		((uint8_t)0x09)		
#define PB4_QSPI1_DIO2		((uint8_t)0x0A)		
#define PB4_TIM3_BKIN		((uint8_t)0x0B)		
#define PB4_TIM10_TOG		((uint8_t)0x0C)		
#define PB4_BEEP				((uint8_t)0x0D)		
#define PB4_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PB5 selection  
  */ 
#define PB5_USART0_RX		((uint8_t)0x01)		
#define PB5_USART0_TX		((uint8_t)0x02)			
#define PB5_QSPI1_NSS		((uint8_t)0x04)		
#define PB5_QSPI2_NSS		((uint8_t)0x05)		
#define PB5_QSPI2_DIO3		((uint8_t)0x06)		
#define PB5_LPTIM_EXT		((uint8_t)0x07)		
#define PB5_TIM5_CH2		((uint8_t)0x08)		
#define PB5_TIM4_CH2N		((uint8_t)0x09)		
#define PB5_QSPI1_DIO3		((uint8_t)0x0A)		
#define PB5_TIM3_ETR		((uint8_t)0x0B)		
#define PB5_TIM10_GATE	((uint8_t)0x0C)		
#define PB5_LVD_OUT			((uint8_t)0x0D)		
#define PB5_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PB6 selection  
  */ 
#define PB6_USART0_TX		((uint8_t)0x01)		
#define PB6_USART0_RX		((uint8_t)0x02)		
#define PB6_I2C_SCL			((uint8_t)0x03)		
#define PB6_QSPI1_MISO		((uint8_t)0x04)		
#define PB6_QSPI2_MISO		((uint8_t)0x05)		
#define PB6_QSPI2_NSS		((uint8_t)0x06)		
#define PB6_LPTIM_EXT		((uint8_t)0x07)		
#define PB6_TIM5_CH3		((uint8_t)0x08)		
#define PB6_TIM4_CH1N		((uint8_t)0x09)		
#define PB6_QSPI1_NSS		((uint8_t)0x0A)		
//#define PB6_TIM4_CH1N		((uint8_t)0x0B)		
#define PB6_TIM11_TOG		((uint8_t)0x0C)		
#define PB6_BEEP				((uint8_t)0x0D)		
#define PB6_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PB7 selection  
  */ 
#define PB7_USART0_RX		((uint8_t)0x01)		
#define PB7_USART0_TX		((uint8_t)0x02)		
#define PB7_I2C_SDA			((uint8_t)0x03)		
#define PB7_QSPI1_MOSI		((uint8_t)0x04)		
#define PB7_QSPI2_MOSI		((uint8_t)0x05)			
#define PB7_LPTIM_TOG		((uint8_t)0x07)		
#define PB7_TIM5_CH4		((uint8_t)0x08)		
#define PB7_TIM4_ETR		((uint8_t)0x09)			
#define PB7_TIM2_BKIN		((uint8_t)0x0B)		
#define PB7_TIM11_TOGN	((uint8_t)0x0C)		
#define PB7_COMP2_OUT		((uint8_t)0x0D)		
#define PB7_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PB8 selection  
  */ 
#define PB8_USART1_TX		((uint8_t)0x01)		
#define PB8_USART1_RX		((uint8_t)0x02)		
#define PB8_I2C_SCL			((uint8_t)0x03)		
#define PB8_QSPI1_SCK		((uint8_t)0x04)		
#define PB8_QSPI2_SCK		((uint8_t)0x05)		
#define PB8_QSPI2_NSS		((uint8_t)0x06)			
#define PB8_TIM2_CH4		((uint8_t)0x08)		
#define PB8_TIM5_CH2N		((uint8_t)0x09)		
#define PB8_QSPI1_NSS		((uint8_t)0x0A)			
#define PB8_TIM10_TOG		((uint8_t)0x0C)		
#define PB8_LVD_OUT			((uint8_t)0x0D)		
#define PB8_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PF0 selection  
  */ 
#define PF0_USART1_TX		((uint8_t)0x01)		
#define PF0_USART1_RX		((uint8_t)0x02)		
#define PF0_I2C_SDA			((uint8_t)0x03)		
#define PF0_QSPI1_SCK		((uint8_t)0x04)		
#define PF0_QSPI2_SCK		((uint8_t)0x05)				
#define PF0_TIM2_CH1		((uint8_t)0x08)		
#define PF0_TIM5_CH3N		((uint8_t)0x09)			
#define PF0_TIM3_BKIN		((uint8_t)0x0B)			
#define PF0_LVD_OUT			((uint8_t)0x0D)		
#define PF0_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PF1 selection  
  */ 
#define PF1_USART1_RX		((uint8_t)0x01)		
#define PF1_USART1_TX		((uint8_t)0x02)		
#define PF1_I2C_SCL			((uint8_t)0x03)		
#define PF1_QSPI1_MISO		((uint8_t)0x04)		
#define PF1_QSPI2_MISO		((uint8_t)0x05)			
#define PF1_LPTIM_TOGN	((uint8_t)0x07)		
#define PF1_TIM2_CH2		((uint8_t)0x08)		
#define PF1_TIM4_CH1		((uint8_t)0x09)			
#define PF1_TIM5_BKIN		((uint8_t)0x0B)		
#define PF1_TIM10_TOGN	((uint8_t)0x0C)		
#define PF1_LVD_OUT			((uint8_t)0x0D)		
#define PF1_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PF2 selection  
  */   
#define PF2_USART0_TX		((uint8_t)0x01)	
#define PF2_USART0_RX		((uint8_t)0x02)			
#define PF2_QSPI1_MOSI		((uint8_t)0x04)		
#define PF2_QSPI2_MOSI		((uint8_t)0x05)		
#define PF2_MCO					((uint8_t)0x06)		
#define PF2_LPTIM_EXT		((uint8_t)0x07)		
#define PF2_TIM2_CH3		((uint8_t)0x08)		
#define PF2_TIM4_CH2		((uint8_t)0x09)		
#define PF2_QSPI1_NSS		((uint8_t)0x0A)		
#define PF2_TIM2_BKIN		((uint8_t)0x0B)		
#define PF2_TIM10_EXT		((uint8_t)0x0C)		
#define PF2_COMP2_OUT		((uint8_t)0x0D)		
#define PF2_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PF3 selection  
  */ 
#define PF3_USART0_RX		((uint8_t)0x01)		
#define PF3_USART0_TX		((uint8_t)0x02)			
#define PF3_QSPI1_MISO		((uint8_t)0x04)		
#define PF3_QSPI2_MISO		((uint8_t)0x05)		
#define PF3_QSPI2_DIO2		((uint8_t)0x06)		
#define PF3_LPTIM_TOG		((uint8_t)0x07)		
#define PF3_TIM2_CH3		((uint8_t)0x08)		
#define PF3_TIM2_CH1N		((uint8_t)0x09)		
#define PF3_QSPI1_DIO2		((uint8_t)0x0A)		
#define PF3_TIM3_ETR		((uint8_t)0x0B)		
#define PF3_TIM10_TOG		((uint8_t)0x0C)			
#define PF3_EVENTOUT		((uint8_t)0x0E)	

/** 
  * @brief   PF4 selection  
  */ 
#define PF4_USART0_TX		((uint8_t)0x01)		
#define PF4_USART0_RX		((uint8_t)0x02)		
#define PF4_I2C_SCL			((uint8_t)0x03)		
#define PF4_QSPI1_MISO		((uint8_t)0x04)		
#define PF4_QSPI2_MISO		((uint8_t)0x05)		
#define PF4_MCO					((uint8_t)0x06)	
#define PF4_LPTIM_EXT		((uint8_t)0x07)		
#define PF4_TIM2_CH4		((uint8_t)0x08)		
#define PF4_TIM5_CH1N		((uint8_t)0x09)				
#define PF4_TIM11_GATE	((uint8_t)0x0C)		
#define PF4_LVD_OUT			((uint8_t)0x0D)		
#define PF4_EVENTOUT		((uint8_t)0x0E)	


/*
#define IS_GPIO_AF(GPIO_AF)       (((GPIO_AF > 0) &&(GPIO_AF < 9))||(GPIO_AF == 0x0f))
*/
#define IS_GPIO_AF(GPIO_AF) ((GPIO_AF) >= 0x00 && (GPIO_AF) <= 0x0F)

/**
  * @}
  */ 


/**
  * @}
  */

/* Exported types ------------------------------------------------------------*/
/** 
  * @brief   GPIO Init structure definition  
  */ 
typedef struct
{
  unsigned int GPIO_Pin;              /*!< Specifies the GPIO pins to be configured.
                                       This parameter can be any value of @ref GPIO_pins_define */

  GPIODir_TypeDef GPIO_Dir;       /*!< Specifies the operating mode for the selected pins.
                                       This parameter can be a value of @ref GPIODir_TypeDef */

  GPIOSpeed_TypeDef GPIO_Speed;   /*!< Specifies the speed for the selected pins.
                                       This parameter can be a value of @ref GPIOSpeed_TypeDef */

  GPIOOType_TypeDef GPIO_OType;   /*!< Specifies the operating output type for the selected pins.
                                       This parameter can be a value of @ref GPIOOType_TypeDef */

  GPIOPuPd_TypeDef GPIO_PuPd;     /*!< Specifies the operating Pull-up/Pull down for the selected pins.
                                       This parameter can be a value of @ref GPIOPuPd_TypeDef */
	
	GPIODrv_TypeDef GPIO_Drv;     
}GPIO_InitTypeDef;

/** 
  * @brief  Interrupt Init Structure definition  
  */
typedef struct
{
  unsigned int GPIO_Pin;               
  GPIOIntTrigger_TypeDef GPIOInt_Trigger;      
  FunctionalState GPIOInt_Cmd;    
}GPIOInt_InitTypeDef;


/* Exported functions --------------------------------------------------------*/
void GPIO_DeInit(GPIO_TypeDef* GPIOx);
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);

unsigned int GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, unsigned int GPIO_Pin);
unsigned int GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
unsigned int GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, unsigned int GPIO_Pin);
unsigned int GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
void GPIO_SetBits(GPIO_TypeDef* GPIOx, unsigned int GPIO_Pin);
void GPIO_ResetBits(GPIO_TypeDef* GPIOx, unsigned int GPIO_Pin);
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, unsigned int GPIO_Pin, BitAction BitVal);
void GPIO_Write(GPIO_TypeDef* GPIOx, unsigned int PortVal);
void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, unsigned int GPIO_Pin);

void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, unsigned int GPIO_PinSource, unsigned int GPIO_AF);
void GPIO_PinDriverSelect(GPIO_TypeDef* GPIOx,unsigned int GPIO_Pin,GPIODrv_TypeDef Drv);

void GPIO_DBSyncCmd(GPIO_TypeDef* GPIOx,FunctionalState NewState);
void GPIO_DBPinCmd(GPIO_TypeDef* GPIOx,unsigned int GPIO_Pin,FunctionalState NewState);
void GPIO_DBClkCmd(GPIO_TypeDef* GPIOx,FunctionalState NewState);
void GPIO_DBClkSelect(GPIO_TypeDef* GPIOx,unsigned int DBClk);

void GPIOInt_Init(GPIO_TypeDef* GPIOx, GPIOInt_InitTypeDef* GPIOInt_InitStruct);

ITStatus GPIO_GetRawIT(GPIO_TypeDef* GPIOx, unsigned int GPIO_Pin);
ITStatus GPIO_GetIT(GPIO_TypeDef* GPIOx, unsigned int GPIO_Pin);
void GPIO_ClearIT(GPIO_TypeDef* GPIOx, unsigned int GPIO_Pin);

#ifdef __cplusplus
}
#endif

#endif /*__GT32F030_GPIO_H */

/**
  * @}
  */ 

/**
  * @}
  */ 

/************************ (C) COPYRIGHT Giantec Semicondutor Inc *****END OF FILE****/
